var UpdateDatePopover = function () {
  var template = /*html*/ `
    <div class="update-date-popover" v-popover:orderSelectPopover>
      <div class="value-div">
        <div v-if="date!==''">{{moment(date).format('YYYY-MM-DD')}}</div>
        <div v-else style="height:32px"></div>
      </div>
      <el-popover v-model="isShow" ref="orderSelectPopover" placement="top-start" trigger="click" :visible-arrow="true" :title="'修改'+title"
        @show="resetTime">
        <div>
          <el-date-picker style="width:200px;" v-model="showTime" value-format="timestamp" :clearable="false" :editable="false"
            :picker-options="{disabledDate:dateLimit}" :placeholder="'请选择'+title"></el-date-picker>
        </div>
        <div style="margin-top:10px;text-align:center">
          <el-button type="primary" @click="save">修改</el-button>
        </div>
      </el-popover>
    </div>
  `;

  return {
    props: {
      date: {
        required: true
      },
      title: {
        type: String,
        default: '日期'
      },
      maxDate: {
        type: [Number, String],
        default: undefined
      },
      minDate: {
        type: [Number, String],
        default: undefined
      }
    },
    data: function () {
      return {
        moment: moment,
        showTime: this.date,
        isShow:false
      };
    },
    methods: {
      dateLimit: function (time) {
        var maxDate = this.maxDate;
        if (!SysUtil.isEmpty(maxDate)) {
          if (moment(time).isAfter(maxDate, 'day')) {
            return true;
          }
        }

        var minDate = this.minDate;
        if (!SysUtil.isEmpty(minDate)) {
          if (moment(time).isBefore(minDate, 'day')) {
            return true;
          }
        }
        return false;
      },
      resetTime: function () {
        this.showTime = this.date;
      },
      save: function () {
        var showTime = this.showTime;
        if (showTime === '') {
          showTime = null;
        }
        this.$emit('save-date', showTime, this);
      },
      getInputTime: function () {
        return this.showTime;
      }
    },
    template: template
  };
}();